package com.aw.baselib.util;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;

/**
 * @author : hzw
 * @date : 2020/6/2
 */
public class AwManifestUtil {

    /**
     * 获取注册清单metadata value
     * @param context
     * @param metaDataName
     * @return
     */
    public static String getMetaDataValue(Context context, String metaDataName) {
        PackageManager pm = context.getPackageManager();
        ApplicationInfo appinfo;
        String metaDataValue = "defaultvalue";
        try {
            appinfo = pm.getApplicationInfo(context.getPackageName(),PackageManager.GET_META_DATA);
            Bundle metaData = appinfo.metaData;
            metaDataValue = metaData.getString(metaDataName);
            return metaDataValue;
        } catch (Exception e) {
            e.printStackTrace();
        }
        AwLog.d("getMetaDataValue result: " + metaDataValue);
        return metaDataValue;
    }
}
